package cn.silver.module.quartz.controller;

import cn.silver.framework.log.annotation.Log;
import cn.silver.framework.log.enums.OperateEnums;
import cn.silver.framework.mybatis.controller.BaseController;
import cn.silver.framework.openapi.model.Result;
import cn.silver.module.quartz.bean.JobLogBean;
import cn.silver.module.quartz.domain.SysJobLog;
import cn.silver.module.quartz.param.JobLogParam;
import cn.silver.module.quartz.service.ISysJobLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 调度日志操作处理
 *
 * @author Silver.Zhou
 */
@RestController
@Tag(name = "系统监控-任务调度日志管理")
@RequestMapping("/monitor/job/log")
public class SysJobLogController extends BaseController<ISysJobLogService, SysJobLog, JobLogParam, JobLogBean> {

    @Override
    @Resource
    public void setBaseService(ISysJobLogService baseService) {
        this.setTitle("系统监控-任务调度日志管理");
        this.setCode("monitor:log");
        this.baseService = baseService;
    }

    /**
     * 清空定时任务调度日志
     */
    @DeleteMapping("/clean")
    @Operation(summary = "清空定时任务调度日志")
    @Log(title = "调度日志", operate = OperateEnums.ALTER_REMOVE)
    public Result<Void> clean() {
        baseService.cleanJobLog();
        return Result.ok();
    }
}
